#!/bin/bash
rm rootfs.i686.cpio.* 2>/dev/null

rm rootfs/* -r
mkdir rootfs/mnt
cp /usr/i686-gentoo-linux-gnu/* rootfs/ -r
cp etc_back/* rootfs/etc/ -r
cp minibackup.sh rootfs/bin/
chmod 555 rootfs/bin/minibackup.sh
rm rootfs/etc/portage -r
rm rootfs/etc/make.conf -r
rm rootfs/usr/include -r
rm rootfs/usr/share/zoneinfo -r
rm rootfs/usr/share/locale -r
rm rootfs/usr/share/i18n -r
rm rootfs/usr/lib/python* -r 2>/dev/null
rm rootfs/sys-include
rm rootfs/tmp/* -r
rm rootfs/var/* -r
rm rootfs/packages -r
rm rootfs/usr/lib/*.a 2>/dev/null #static lib only used while compile programs
rm rootfs/usr/lib/libstdc* 2>/dev/null #while there is libstdc++.so.6.* already relay in rootfs/lib/, other version libstdc++ is no used.

cd rootfs
ln -s sbin/init init
#find . | cpio --quiet -o -H newc | gzip > ../rootfs.i686.cpio.gz
find . | cpio --quiet -o -H newc | lzma > ../rootfs.i686.cpio.lzma
cd ..
#mksquashfs rootfs/* rootfs.i686.squashfs
